<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
	<constant name="struts.enable.DynamicMethodInvocation" value="false" />
	<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
	<constant name="struts.devMode" value="true" />
	<constant name="struts.action.extension" value="action,pdf" />
	<constant name="struts.i18n.reload" value="true" />
	<constant name="struts.configuration.xml.reload" value="true" />
	<constant name="struts.date.format" value="yyyy-MM-dd" />
	<constant name="struts.serve.static" value="true" />
	<constant name="struts.serve.static.browserCache" value="false" />

	<package name="defaultJson" namespace="/" extends="json-default">
		<action name="ajaxAction" class="it.apiconsulting.sharem.action.json.AjaxJsonAction">
			<result type="json">
				<param name="excludeNullProperties">true</param>
				<param name="noCache">true</param>
			</result>
		</action>
	</package>

	<package name="defaultAction" namespace="/" extends="struts-default">
		<result-types>
			<result-type name="tiles"
				class="org.apache.struts2.views.tiles.TilesResult" />
		</result-types>

		<interceptors>
			<interceptor name="sessionInterceptor"
				class="it.apiconsulting.sharem.session.SessionInterceptor" />

			<interceptor-stack name="tstSessionCheckStack">
				<interceptor-ref name="sessionInterceptor" />
				<interceptor-ref name="defaultStack" />
			</interceptor-stack>
		</interceptors>
		<default-interceptor-ref name="tstSessionCheckStack" />

		<default-action-ref name="indexLogin" />

		<global-results>
			<result name="sessionexpired">sessionexpired.jsp</result>
		</global-results>

		<!-- UTENTE -->
		<action name="loginUtente" class="it.apiconsulting.sharem.controller.LoginAction"
			method="loginUtente">
			<result name="success" type="chain">homePageUtente</result>
			<result name="error">index.jsp</result>
		</action>
		<action name="logoutUtente" class="it.apiconsulting.sharem.controller.LoginAction"
			method="logoutUtente">
			<result name="success">index.jsp</result>
		</action>
		<action name="homePageUtente"
			class="it.apiconsulting.sharem.controller.HomePageAction" method="execute">
			<result name="success" type="tiles">welcomeUtente</result>
		</action>

		<!-- GUEST -->
		<action name="loginGuest" class="it.apiconsulting.sharem.controller.LoginAction"
			method="loginGuest">
			<result name="success" type="chain">homePageGuest</result>
			<result name="error">index.jsp</result>
		</action>
		<action name="logoutGuest" class="it.apiconsulting.sharem.controller.LoginAction"
			method="logoutGuest">
			<result name="success">index.jsp</result>
		</action>
		<action name="homePageGuest"
			class="it.apiconsulting.sharem.controller.HomePageAction" method="execute">
			<result name="success" type="tiles">welcomeGuest</result>
		</action>

		<!-- ################################################################################## -->
		<action name="registerUtente"
			class="it.apiconsulting.sharem.controller.RegisterUtenteAction"
			method="execute">
			<result name="success" type="tiles">registerUtente</result>
		</action>
		<action name="registerUtenteForm"
			class="it.apiconsulting.sharem.controller.RegisterUtenteAction"
			method="save">
			<result name="success" type="tiles">welcomeUtente</result>
			<result name="error" type="chain">registerUtenteForm</result>
		</action>

		<!-- ################################################################################## -->
		<action name="registerGuest"
			class="it.apiconsulting.sharem.controller.RegisterGuestAction"
			method="execute">
			<result name="success" type="tiles">registerGuest</result>
		</action>
		<action name="registerGuestForm"
			class="it.apiconsulting.sharem.controller.RegisterGuestAction"
			method="save">
			<result name="success" type="tiles">welcomeGuest</result>
			<result name="error" type="chain">registerGuestForm</result>
		</action>

		<!-- ################################################################################## -->
		<action name="mediaPlayer"
			class="it.apiconsulting.sharem.controller.MediaPlayerAction" method="execute">
			<result name="success" type="tiles">mediaPlayer</result>
			<result name="login">index.jsp</result>
		</action>

		<!-- ################################################################################## -->
		<action name="registerPlaylist"
			class="it.apiconsulting.sharem.controller.PlaylistAction" method="execute">
			<result name="success" type="tiles">creaPlaylist</result>
		</action>
		<action name="registerPlaylistForm"
			class="it.apiconsulting.sharem.controller.PlaylistAction" method="save">
			<interceptor-ref name="fileUpload">
				<param name="allowedTypes">audio/mp3,audio/x-wav,audio/mpeg,audio/ogg,audio/wav</param>
			</interceptor-ref>
			<param name="maximumSize">31457280</param>
			<interceptor-ref name="params">
				<param name="excludeParams">dojo\..*,^struts\..*</param>
			</interceptor-ref>
			<interceptor-ref name="validation" />
			<interceptor-ref name="workflow" />

			<result name="success" type="chain">mediaPlayer</result>
		</action>

	</package>
</struts>